public class ClientClass {
    public static void main(String[] args) {
        Factory factory = new Factory();
        Caretaker caretaker = new Caretaker();

        // 创建水果并保存状态
        Fruit fruit = factory.createFruit("A");
        caretaker.saveMemento(factory.saveToMemento());
        fruit.eat();  // 输出 eat Apple

        // 恢复历史状态
        Memento memento = caretaker.getMemento();
        Fruit restoredFruit = factory.restoreFromMemento(memento);
        restoredFruit.eat();  // 再次输出 eat Apple
    }
}